From: Julien Moutinho Date: Sat, 15 Mar 2014 03:07:57 +0000 (+0100) Subject: init X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/%22%7B%24link%5B%27href%27%5D%7D/%40%20%27icone_configuration%27%20=%3E%20%27Configuration%27%2C%20%27icone_creer_auteur%27%20=%3E%20%27Create%20a%20new%20author%20and%20associate%20him/her%20with%20this%20article%27%2C%20%27icone_creer_mot_cle%27%20=%3E%20%27Create%20a%20new%20keyword%20and%20link%20it%20to%20this%20article%27%2C-%27icone_creer_mot_cle_rubrique%27%20=%3E%20%27Create%20a%20new%20keyword%20and%20attach%20it%20to%20this%20section%27%2C-%27icone_creer_mot_cle_site%27%20=%3E%20%27Create%20a%20new%20keyword%20and%20attach%20it%20to%20this%20site%27%2C%20%27icone_creer_rubrique_2%27%20=%3E%20%27Create%20a%20new%20section%27%2C%20%27icone_edition%27%20=%3E%20%27Edit%27%2C-%27icone_envoyer_message%27%20=%3E%20%27Send%20this%20message%27%2C%20%27icone_ma_langue%27%20=%3E%20%27My%20language%27%2C%20%27icone_mes_infos%27%20=%3E%20%27My%20details%27%2C%20%27icone_mes_preferences%27%20=%3E%20%27Preferences%27%2C%20%27icone_modifier_article%27%20=%3E%20%27Edit%20this%20article%27%2C-%27icone_modifier_message%27%20=%3E%20%27Edit%20this%20message%27%2C%20%27icone_modifier_rubrique%27%20=%3E%20%27Edit%20this%20section%27%2C%20%27icone_publication%27%20=%3E%20%27Publish%27%2C%20%27icone_relancer_signataire%27%20=%3E%20%27Contact%20the%20signatory%20again%27%2C%40%40%20-220%2C15%20%20188%2C11%20%40%40%20Do%20not%20submit%20this%20import%20request.%3Cp%3EFor%20more%20information%2C%20please%20see%20%3Ca%20href=?a=commitdiff_plain;p=ikiwiki%2Faction.git init --- e6e723b62839efd4c2a8d2995a8143f29e806a4b diff --git a/action.pm b/action.pm new file mode 100644 index 0000000..aa9de88 --- /dev/null +++ b/action.pm @@ -0,0 +1,60 @@ +#!/usr/bin/perl + # This file is une extension à IkiWiki + # permettant d’ajouter des actions aux pages. + # Copyright (C) 2010 Julien Moutinho + # + # This program is free software: you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published + # by the Free Software Foundation, either version 3 of the License, + # or any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty + # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + # See the GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program. If not, see . +package IkiWiki::Plugin::action; +use warnings; +use strict; +use IkiWiki 3.00; +sub import { + IkiWiki::hook + ( type => "preprocess" + , id => "action" + , call => \&hook_preprocess_action ); + IkiWiki::hook + ( type => "pageactions" + , id => "action" + , call => \&hook_preprocess_pageactions ); + } +my %map; +sub hook_preprocess_pageactions(@) { + my %env = @_; + my $page = $env{page}; + my @lst; + if (defined $page and exists $map{$page}) { + foreach (@{$map{$page}}) { + push @lst, $_; + } + } + return @lst; + } +sub hook_preprocess_action(@) { + my %env = @_; + my $page = $env{page}; + if (exists $env{html} and defined $env{html}) { + if (length $env{html}) { + $map{$page} = [] + if not defined $map{$page}; + push @{$map{$page}}, "$env{html}"; + } + else { + delete $map{$page}; + } + } + return ""; + } + +1;